package me.keiwu.admin.controller.rpc;

import me.keiwu.admin.domain.config.Config;
import me.keiwu.admin.service.ConfigService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;


/**
 * Created by kei on 27/11/2017.
 */
@RequestMapping("/rpc/config")
@RestController
public class ConfigRpcController {

    private static final Logger logger = LoggerFactory.getLogger(ConfigRpcController.class);

    @Autowired
    private ConfigService configService;

    @ResponseBody
    @RequestMapping(value = "/get")
    public String getConfig(Integer configType){
        Config config = configService.getConfig(configType);
        return config.getConfigJson();
    }

    @ResponseBody
    @RequestMapping(value = "/get/all")
    public Iterable<Config> getAllConfig(){
        return configService.getAllConfig();
    }

}
